import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';
const db = wx.cloud.database()
const app = getApp()
Page({
  data: {
    appointment_complete_logs: []
  },
  onLoad: function (options) {
    this.refresh()
  },
  refresh() {
    db.collection("appointment_log").where({
      _openid: app.globalData.openId
    }).get().then(res => {
      this.setData({
        appointment_complete_logs: res.data
      })
    })
  },
  onShow: function () {

  },
  onShareAppMessage: function () {

  },
  delete_log(e) {
    Dialog.confirm({
        title: '提示',
        message: '是否删除此条预约记录?',
      }).then(() => {
        db.collection("appointment_log").doc(e.target.id).remove().then(r => {
          this.refresh()
        })
      })
      .catch(() => {
      });
  }
})